#include "widget.h"
#include "ui_widget.h"
#include "QPainter"
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::paintEvent(QPaintEvent *event)
{
    (void)event;

    QPainter painter(this);//this是指定设备

    //    painter.drawLine(20, 20, 200, 20);

    //    painter.drawLine(QPoint(20,100), QPoint(200, 100));

    //    painter.drawRect(100, 100, 300, 200);

    //    painter.drawEllipse(200,200,100,100);//外接矩形的宽高

//    QFont font("微软雅黑", 24);
//    painter.setFont(font);
//    painter.drawText(0,100,"hello");//0表示文字最左侧，100是文字基线位置

    QPen pen;
    pen.setColor(QColor(255,0,0));
    pen.setWidth(Qt::DashLine);
    painter.setPen(pen);
//    painter.drawEllipse(200,200,100,100);

    QBrush brush;
    brush.setColor(QColor(0,255,0));
    brush.setStyle(Qt::SolidPattern);
    painter.setBrush(brush);
    painter.drawEllipse(200,200,100,100);
}

